<template>
  <div class="app-container">
    <!--    隐藏域 记录id-->

    <el-form ref="form" :model="announcement" label-width="120px">
      <el-form-item label="标题">
        <el-input type="text" v-model="announcement.title" />
      </el-form-item>
      <el-form-item label="内容">
        <el-input  type="text" v-model="announcement.content" />
      </el-form-item>


      <el-form-item label="发布日期">
        <el-date-picker type="datetime"  v-model="announcement.cdate" placeholder="选择发布时间" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button type="primary"  @click="onSubmit">新增公告</el-button>
        <el-button @click="onCancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import request from '@/utils/request'
export default {
  data() {
    return {
      announcement:{
        id:0,
        title:"",
        content:"",
        cdate:"",
      },

    }
  },
  mounted() {


  },
  methods: {
    onSubmit() {
      // 请求接口 实现用户新增接口的调用
      request({
        url:"/library/announcement/save.do",
        method: "POST",
        data:this.announcement
      }).then(res=>{
        if(res.code==0){
          //跳转到列表页面
          this.$router.push("/announcementlist");
        }
      })
    },
    checkPass() {},
    onCancel() {
      this.$message({
        message: '取消公告的新增',
        type: 'warning'

      }),
        this.$router.push("/announcementlist");
    }
  }
}
</script>

<style scoped>
.line{
  text-align: center;
}
</style>

